package com.zyuan.lawyerport.presenter.guild;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import com.zyuan.lawyerport.MainActivity;
import com.zyuan.lawyerport.R;
import com.bigkoo.convenientbanner.ConvenientBanner;
import com.bigkoo.convenientbanner.holder.Holder;

import common.tool.PUB;

/**
 * description
 * Created by JustTong on 2018/12/13.
 */
public class NetImageHolderView extends Holder<NhvBean> {

    private Activity mActivity;
    private ImageView imgMain;
    private ImageView imgClick;
    private String mVersionCode;
    private ConvenientBanner mConvenientBanner;

    public NetImageHolderView(View itemView, Activity activity, String getVersionCode, ConvenientBanner wellcomeConvenient) {
        super(itemView);
        this.mActivity = activity;
        this.mVersionCode = getVersionCode;
        this.mConvenientBanner = wellcomeConvenient;
    }

    @Override
    protected void initView(View itemView) {
        imgMain = itemView.findViewById(R.id.img_main);
        imgClick = itemView.findViewById(R.id.img_click);
        imgClick.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PUB.SharedPreferences(mActivity, "firstInIdentifying", mVersionCode);//版本存入，下次比较直接跳过
                mActivity.startActivity(new Intent(mActivity, MainActivity.class));
                mActivity.finish();
            }
        });
    }

    @Override
    public void updateUI(NhvBean data) {
        if (data.getPosition() == 3) {
            mConvenientBanner.setPointViewVisible(false);
            imgClick.setVisibility(View.VISIBLE);
        } else {
            mConvenientBanner.setPointViewVisible(true);
            imgClick.setVisibility(View.GONE);
        }

//            try {
//                imgMain.setImageResource(mList.get(position));
//            } catch (Exception ex) {
//                Logger.w(ex.toString());
//            }

        imgMain.setImageResource(data.getData());
    }

}